<?php
/**
 * Created by Yury Patrin.
 * Time: 15.12.13 15:06
 */

class Search extends CI_Controller
{
    protected $user;

    public function __construct()
    {
        parent::__construct();
        $this->load->library('session');

        $this->load->model('user_model');
        $this->load->model('group_model');

        $this->user = $this->session->userdata('user');
        $this->_checkLogin();
    }

    public function user($email)
    {
        $users = $this->user_model->getUsersByEmailMask($email);
        $groups = $this->group_model->getGroupsList();

        $content = $this->load->view('pages/users', ['users' => $users, 'groups' => $groups, 'sw' => $email], true);
        $this->load->view('admin_page', ['activePage' => 'users', 'user' => $this->user, 'content' => $content]);
    }

    protected function _checkLogin()
    {
        $loginStatus = $this->session->userdata('login');

        if ($loginStatus != "true")
            redirect('index');
    }
}